package com.woniuxy.usercoachassemble.configuration;

import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.simp.config.MessageBrokerRegistry;
import org.springframework.web.socket.config.annotation.AbstractWebSocketMessageBrokerConfigurer;
import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker;
import org.springframework.web.socket.config.annotation.StompEndpointRegistry;

/**
 * ClassName: WebSocketConfig
 * Description:
 * date: 2020/7/16 10:03
 *
 * @author Fy浪迹、
 */
@Configuration
@EnableWebSocketMessageBroker
public class WebSocketConfig extends AbstractWebSocketMessageBrokerConfigurer {
    //注册STOMP协议节点，同时指定使用SockJS协议。
    @Override
    public void registerStompEndpoints(StompEndpointRegistry registry) {
        registry.addEndpoint("/endpointClinical").setAllowedOrigins("*").withSockJS();
    }

    //由于我们是实现推送功能，这里的消息代理是/topic
    @Override
    public void configureMessageBroker(MessageBrokerRegistry config) {
        //启动STOMP 代理中继功能，并将其代理目的地前缀设置为 "/queue"
        config.enableSimpleBroker("/topic");
//应用程序开头
//config.setApplicationDestinationPrefixes("/app");
    }
}
